function addEvent(el, type, fn) {
  if (el.addEventListener) {
    el.addEventListener(type, fn, false);
  } else if (el.attachEvent) {
    el.attachEvent('on' + type, function() {
      fn.call(el);
    });
  } else {
    console.log(11);
    el['on' + type] = fn;
  }
}

function elemChildren(node) {
  var temp = {
      'length': 0,
      'splice': Array.prototype.splice,
    },
    children = node.childNodes;
  for (var i = 0; i < children.length; i++) {
    var childItem = children[i];
    if (childItem.nodeType === 1) {
      temp[temp['length']] = childItem;
      temp['length']++;
    }
  }
  return temp;
}

function elemParent(node, n) {
  var buffer = node;
  for (var i = 0; i < n; i++) {
    buffer = buffer.parentNode;
    if (buffer === null) {
      return undefined;
    }
  }
  return buffer;
}
